import getApiData from "@/services/cpasRequest";
import notify from 'devextreme/ui/notify';

//  初始化需重分类的数据
export async function adjustingEntryInit(params: {
  dbname: string,
  billID: string,
  isQC: boolean,
  Data_ID: string
}) {
  const res = await getApiData("account.adjustingEntry.CFL.init", params);
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.resolve({
    data: [],
    success: false,
  });


}


// 获取待重分类一级科目列表
export async function getTopKMMCList(params: {
  dbname: string,
  billID: string,
  Data_ID: string
}) {
  const res = await getApiData("account.adjustingEntry.CFL.getTopKMMCList", params);
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.resolve({
    data: [],
    success: false,
  });
}

// 获取待重分类总账辅助账列表
export async function getDataList(params: {
  dbname: string,
  billID: string,
  Data_ID: string,
  KMMC?: string,
  ZWType?: any,
  isRefresh?: boolean
}) {
  const res = await getApiData("account.adjustingEntry.CFL.getDataList", params);
  if (res.ok) {
    return Promise.resolve({
      data: res.data,
      success: true,
    });
  }
  return Promise.resolve({
    data: [],
    success: false,
  });
}

// 获取待重分类总账辅助账列表
export async function updateKMMap(params: {
  dbname: string,
  billID: string,
  YSKMBH: string,
  GUID: string,
  YSHSXMBH: string,
  HSXMLXMC: string,
  HSXMLXBH: string,
  KMMC: string,
  KMBH: string,
  HSXMMC: string,
  HSXMBH: string,
  YSHSXMMC: string,
  itemNames3: string,
  YSKMMC: string,
}) {
  const res = await getApiData("account.adjustingEntry.CFL.updateKMMap", params);
  return res.ok;
}


// 更新全部待重分类记录的选中状态
export async function updateSelectState(params: {
  dbname: string,
  billID: string,
  KMMC?: string,
  ZWType?: string | number,
  isSelected: boolean,
}) {
  const res = await getApiData("account.adjustingEntry.CFL.updateSelectState.all", params);
  return res.ok;
}

// 更新记录选中
export async function updateSelectStateAdjustingEntry(params: {
  dbname: string,
  billID: string,
  isSelected: boolean,
  GUIDs: any
}) {
  const res = await getApiData("account.adjustingEntry.CFL.updateSelectState", params);
  return res.ok;
}

//  完成待重分类记录设置，增加选中的重分类记录到调整分录。
export async function AdjustingEntrySave(params: {
  dbname: string,
  billID: string,
  Data_ID: string,
  isQC: boolean
}) {
  const res = await getApiData("account.adjustingEntry.CFL.save", params);
  return res.ok;
}


//  重分类自动解析对方科目信息
export async function KMMapanalysisMap(params: {
  dbname: string,
  billID: string,
  Data_ID: string,
}) {
  const res = await getApiData("account.adjustingEntry.CFL.KMMap.analysisMap", params);
  return res.ok;
}







